
import user from "../../../../store/modules/user";
import _ from 'lodash';
import { getAction, deleteAction, putAction, postAction, httpAction } from '@/api/manage'
// 配置列表项
const JumpConfigList = {
    yd: {
        name: 'sj-sjmxgl-yjcg-yjcgscq',
        params: {},
    },
}
//  工程信息阅帐跳转需要的参数
const EngineeringInformationConfig = {
    sbjc: {
        modelName: "设备进场管理",
        pid: "046e213cb3bf146ec0dcb21132c2df3",
        id: "046e213cb3bf146ec0dcb21132c23c57"
    },
    sbcc: {
        modelName: "设备出场管理",
        pid: "046e213cb3bf146ec0dcb21132c2df3",
        id: "5e9342efa33a093d5b2c941da59b31a6"
    },
    wzxx: {
        modelName: "设备出场管理",
        pid: "0",
        id: "db84130be400cb511726a5fb5ad61f25"
    },
    fbdw: {
        modelName: "分包队伍查看",
        pid: "e64079ce56a16f8c4cfc05519b6768cd",
        id: "c720b7b884e22dfcb930ceb1004fc781"
    },

    hgfbs: {
        modelName: "合格分包商查看",
        pid: "e64079ce56a16f8c4cfc05519b6768cd",
        id: "f2c8bd472c33a982cae28ee3683b7551"
    },

    hmd: {
        modelName: "黑名单查看",
        pid: "e64079ce56a16f8c4cfc05519b6768cd",
        id: "f78209d33b4831744d34916b2bce1f7b"
    },

    htxx: {
        modelName: "合同信息阅账",
        pid: "0",
        id: "02fe3cb18885c126aedcacf2ee74e429"
    },

}

/**
 *     动态获取辅助工具中显示的数据    该数据与菜单数据有关
 */
let permissionList = user.state.permissionList
//  审计辅助模型
let SjmxgjMenuList = []
//  查阅分析辅助工具
let CyfxfzMenuList = []

//  工程信息阅帐
permissionList.map(item => {
    try {
        if (item.children && item.children.length > 0 && item.meta.title == '审计模型管理') {
            // let mxgl = _.cloneDeep(item.children)
            let mxgl = item.children.filter(item => {
                return item.meta.title != '疑点一键梳理' && item.meta.title != '审计模型配置'
            })
           

            SjmxgjMenuList = [..._.cloneDeep(mxgl)]
        } else if (item.children && item.children.length > 0 && item.meta.title == '智能分析工具') {
            let yzzx = item.children.filter(item => {
                return item.meta.title === '科目分析视图' || item.meta.title === '指标分析视图'
            })
            CyfxfzMenuList = [..._.cloneDeep(yzzx)]
        }
    } catch (error) {
        console.log(error);
    }
})

console.log(SjmxgjMenuList,CyfxfzMenuList);
export {
    SjmxgjMenuList,
    CyfxfzMenuList
}


/**
 * 
 * @param {*} model  传入的数据，从弹窗中得到数据，拼接跳转参数
 * @returns 
 */
//  处理跳转到疑点需要的参数------一键成稿生成器
function handeleJumpYd(model) {
    // 从详情数据记录中获取关键的信息，
    let { id, name, stageText, number, type_dictText, bsjdwName, startDate, endDate } = model
    let params = {
        id,
        name,
        returnRecord: JSON.stringify({
            id,
            name,
            stageText,
            number,
            type_dictText,
            bsjdwName,
            startDate,
            endDate,
        }),
    }

    return params
}

/**
 * 项目实施跳转到任何页面
 * @param {*} jumpItem 自定义的名字，例如：疑点一键梳理 对应 yd
 * @param {} componentName  当跳转过去需要组件切换，需要传递要组件名字，所以这个是可填可不填
 * @param {*} params  由路由带过去的参数
 * @returns 
 */
export default async function JumpConfig(jumpItem, componentName, model) {
    // from:'sjxmss'  检测路由时的标识
    let params = {
        from: 'sjxmss'
    }
    if (Object.keys(EngineeringInformationConfig).includes(componentName)) {
        params.EngineeringInformation = { ...EngineeringInformationConfig[componentName] }
    } else if (componentName)
        params.componentName = componentName


    //  请求各种条件
    let res = await getAction('/sjyzzx/sjWorkTool/queryBalanceList', { proid: model.id })

    // switch (jumpItem) {
    //     // case 'sjxmzygl-yzzx-kmmx':
    //     // case 'sjxmzygl-yzzx-kmye':
    //     //     let result = await getAction('/sjyzzx/sjWorkTool/queryBalanceList', { proid: model.id })
    //     //     params = Object.assign({}, params, handeleJumpYd(model), { ...result.result[0] })
    //     //     break;
    //     case 'sj-sjmxgl-yjcg-yjcgscq':
    //         params = Object.assign({}, params, handeleJumpYd(model),{ ...res.result[0] })
    //         break;
    //     default:

    //         if (res.result) {
    //             params = Object.assign({}, params, handeleJumpYd(model), { ...res.result[0] })
    //         } else {
    //             params = {}
    //         }
    // }

    if (res.result.length && res.result) {
        params = Object.assign({}, params, handeleJumpYd(model), { ...res.result[0] })
    } else {
        params = Object.assign({}, params, handeleJumpYd(model))
    }
    return params
}
// 返回时调用的方法